home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / gnat1792.zip / gnat179b / t-adainc / a-strunb.ads < prev    next >
Text File  |  1994-05-19  |  7KB  |  226 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --                A D A . S T R I N G S . U N B O U N D E D                 --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.4 $                              --
  10. --                                                                          --
  11. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. --
  22. --                                                                          --
  23. ------------------------------------------------------------------------------
  24.  
  25.  
  26. with Ada.Strings.Maps;
  27.  
  28. package Ada.Strings.Unbounded is
  29.  
  30.    Blank : constant Character := ' ';
  31.  
  32.    type Unbounded_String is private;
  33.  
  34.    Null_Unbounded_String : constant Unbounded_String;
  35.  
  36.    type String_Access is access all String;
  37.  
  38.    ----------------------------
  39.    -- String Length Function --
  40.    ----------------------------
  41.  
  42.    function Length (Source : Unbounded_String) return Natural;
  43.  
  44.    -----------------------------------------------------
  45.    -- Conversion, Catenation, and Selection Functions --
  46.    -----------------------------------------------------
  47.  
  48.    function To_Unbounded_String (Source : String)
  49.       return Unbounded_String;
  50.  
  51.    function To_String (Source : Unbounded_String) return String;
  52.  
  53.    function "&" (Left, Right : Unbounded_String)
  54.       return Unbounded_String;
  55.  
  56.    function "&" (Left : Unbounded_String; Right : String)
  57.       return Unbounded_String;
  58.  
  59.    function "&" (Left : String; Right : Unbounded_String)
  60.       return Unbounded_String;
  61.  
  62.    function "&" (Left : Unbounded_String; Right : Character)
  63.       return Unbounded_String;
  64.  
  65.    function "&" (Left : Character; Right : Unbounded_String)
  66.       return Unbounded_String;
  67.  
  68.    function Element
  69.      (Source : Unbounded_String;
  70.       Index  : Positive)
  71.       return   Character;
  72.  
  73.    procedure Replace_Element
  74.      (Source : in out Unbounded_String;
  75.       Index  : Positive;
  76.       By     : Character);
  77.  
  78.    function Slice
  79.      (Source : Unbounded_String;
  80.       Low    : Positive;
  81.       High   : Natural)
  82.       return   String;
  83.  
  84.    function "="  (Left, Right : Unbounded_String) return Boolean;
  85.  
  86.    function "<"  (Left, Right : Unbounded_String) return Boolean;
  87.    function "<=" (Left, Right : Unbounded_String) return Boolean;
  88.    function ">"  (Left, Right : Unbounded_String) return Boolean;
  89.    function ">=" (Left, Right : Unbounded_String) return Boolean;
  90.  
  91.    ------------------------
  92.    -- Search Subprograms --
  93.    ------------------------
  94.  
  95.    function Index
  96.      (Source   : Unbounded_String;
  97.       Pattern  : String;
  98.       Going    : Direction := Forward;
  99.       Mapping  : Maps.Character_Mapping := Maps.Identity)
  100.       return     Natural;
  101.  
  102.    function Index
  103.      (Source : Unbounded_String;
  104.       Set    : Maps.Character_Set;
  105.       Test   : Membership := Inside;
  106.       Going  : Direction  := Forward)
  107.       return   Natural;
  108.  
  109.  
  110.    function Index_Non_Blank
  111.      (Source : Unbounded_String;
  112.       Going  : Direction := Forward)
  113.       return   Natural;
  114.  
  115.    function Count
  116.      (Source  : Unbounded_String;
  117.       Pattern : String;
  118.       Mapping : Maps.Character_Mapping := Maps.Identity)
  119.       return    Natural;
  120.  
  121.    function Count
  122.      (Source : Unbounded_String;
  123.       Set    : Maps.Character_Set)
  124.       return   Natural;
  125.  
  126.  
  127.    procedure Find_Token
  128.      (Source : Unbounded_String;
  129.       Set    : Maps.Character_Set;
  130.       Test   : Membership;
  131.       First  : out Positive;
  132.       Last   : out Natural);
  133.  
  134.    ------------------------------------
  135.    -- String Translation Subprograms --
  136.    ------------------------------------
  137.  
  138.    function Translate
  139.      (Source  : Unbounded_String;
  140.       Mapping : Maps.Character_Mapping)
  141.       return    Unbounded_String;
  142.  
  143.    procedure Translate
  144.      (Source  : in out Unbounded_String;
  145.       Mapping : Maps.Character_Mapping);
  146.  
  147.    ---------------------------------------
  148.    -- String Transformation Subprograms --
  149.    ---------------------------------------
  150.  
  151.    function Replace_Slice
  152.      (Source : Unbounded_String;
  153.       Low    : Positive;
  154.       High   : Natural;
  155.       By     : String)
  156.       return   Unbounded_String;
  157.  
  158.  
  159.    function Insert
  160.      (Source   : Unbounded_String;
  161.       Before   : Positive;
  162.       New_Item : String)
  163.       return     Unbounded_String;
  164.  
  165.  
  166.    function Overwrite
  167.      (Source   : Unbounded_String;
  168.       Position : Positive;
  169.       New_Item : String)
  170.       return     Unbounded_String;
  171.  
  172.  
  173.    function Delete
  174.      (Source  : Unbounded_String;
  175.       From    : Positive;
  176.       Through : Natural)
  177.       return    Unbounded_String;
  178.  
  179.    function Trim
  180.      (Source : Unbounded_String)
  181.       return   Unbounded_String;
  182.  
  183.    function Trim
  184.      (Source : Unbounded_String;
  185.       Left   : Maps.Character_Set;
  186.       Right  : Maps.Character_Set)
  187.       return   Unbounded_String;
  188.  
  189.    function Head
  190.      (Source : Unbounded_String;
  191.       Count  : Natural;
  192.       Pad    : Character := Blank)
  193.       return   Unbounded_String;
  194.  
  195.    function Tail
  196.      (Source : Unbounded_String;
  197.       Count  : Natural;
  198.       Pad    : Character := Blank)
  199.       return   Unbounded_String;
  200.  
  201.    function "*"
  202.      (Left  : Natural;
  203.       Right : Character)
  204.       return  Unbounded_String;
  205.  
  206.    function "*"
  207.      (Left  : Natural;
  208.       Right : String)
  209.       return  Unbounded_String;
  210.  
  211.    function "*"
  212.      (Left  : Natural;
  213.       Right : Unbounded_String)
  214.       return  Unbounded_String;
  215.  
  216. private
  217.  
  218.    type Unbounded_String is record
  219.       Reference : String_Access := new String'("");
  220.    end record;
  221.  
  222.    Null_Unbounded_String : constant Unbounded_String :=
  223.                                (Reference => new String'(""));
  224.  
  225. end Ada.Strings.Unbounded;
  226.